<?php
class university{

	function selectUniversity()
	{
		global $con;
		$sql="select * from tbl_university";
		$res = mysqli_query($con,$sql);
		return $res;
	}
	function addUniversity($uni_name,$uni_price,$uni_details,$uni_image,$uni_status, $cat_id, $cat_name, $date)
	{
				global $con;
				$sql="INSERT INTO tbl_university
				SET 
				university_name='$uni_name',
				university_price='$uni_price',
				university_des='$uni_details',
				university_image='$uni_image',
				university_status='$uni_status',
				university_cat_id='$cat_id',
				university_country='$cat_name',
				university_added_date='$date'";
				
				$res=mysqli_query($con,$sql);
				return $res;
	}
	function deleteUniversity($uni_id)
	{
		global $con;
		$sql="DELETE FROM tbl_university WHERE university_id='$uni_id'";
		$res=mysqli_query($con,$sql);	
	}
	function editUniversity($uni_id,$uni_name,$uni_price,$uni_details,$uni_image,$uni_status,$cat_id,$cat_name,$date)
	{
		global $con;
		$sql="UPDATE tbl_university SET 
			university_name='$uni_name',
			university_price='$uni_price',
			university_des='$uni_details',
			university_image='$uni_image',
			university_status='$uni_status',
			university_cat_id='$cat_id',
			university_country='$cat_name',
			university_added_date='$date'
			WHERE
			university_id='$uni_id'";
		$res=mysqli_query($con,$sql);
		
	}
	function getUniversityById($id)
	{
		global $con;
		$sql="SELECT *FROM tbl_university WHERE university_id='$id'";
		$res=mysqli_query($con,$sql);
		return $res;
	}
	function universityStatus($status,$uni_id)
	{
		global $con;
		$sql="UPDATE tbl_university SET university_status='$status' WHERE university_id='$uni_id'";
		$res=mysqli_query($con,$sql);
	}
	function selectFeatureUniversity()
	{
		global $con;
		
		$sql="SELECT *FROM tbl_university WHERE university_status='1'";
		//$res=mysqli_query($con,$sql);
		$i=0;
		$data=array();
		$qry_result=mysqli_query($con,$sql) or die("QUERY ERROR1=>".mysql_error());
		 //$qry_row=mysql_fetch_assoc($qry_result);
		while ($row=mysqli_fetch_object($qry_result)) {
          	$data[$i] = $row;
          	$i++;
			  }
		return $data;
	}
	function UniversityByCatId($catId)
	{
		global $con;
		$sql="SELECT *FROM tbl_university WHERE university_cat_id='$catId'";
		$res=mysqli_query($con,$sql);
		return $res;
		
	}
	function searchUniversity($keyword)
	{
		global $con;
		$sql="SELECT *FROM tbl_university WHERE university_name LIKE '%$keyword%'";
		$res=mysqli_query($con,$sql);
		return $res;
	}
}
$objUniversity=new university();
?>